
import React from 'react';
import { Layout, Menu, Breadcrumb, Icon } from 'antd';
import './index.css'
import {Route,Link} from 'react-router-dom'
import CapaCityTable1 from '../capacitymeun/CapaCityTable1'
import CapaCityTable2 from '../capacitymeun/CapaCityTable2'
import CapaCityTable3 from '../capacitymeun/CapaCityTable3'
import CapaCityTable4 from '../capacitymeun/CapaCityTable4'
import CapaCityTable5 from '../capacitymeun/CapaCityTable5'
import ClassiFicationList from '../classification/ClassiFicationList'
import {withRouter } from 'react-router-dom'
import Transport from '../transport/Transport'
import { connect } from 'react-redux'
import {fullCapacity} from '../../redux/capacitymeun/menuList'
import { ClassMenu}  from '../../redux/classFicationg/classFication'
import ClassIficationList1 from '../classification/ClassIficationList1'
import ClassList from '../classification/ClassList'
import AddClassModel from './AddClassModel'
const MenuItemGroup = Menu.ItemGroup;
const { SubMenu } = Menu;
const { Header, Content, Sider } = Layout;
@withRouter
@connect(
    state => state,
    { fullCapacity,ClassMenu }
)
export default class TransportMenuList extends React.Component{
    constructor(){
        super();
        this.state = {
            visible1:false
        }
    }
    showModel(){
        this.setState({
            visible1:!this.state.visible1
        })
    }
    componentWillReceiveProps(nextProps){
        if(nextProps.classList.isADD){
            this.props.ClassMenu();
        }
    }
         this.props.history.push('/menuList/CapaCityTable1/1')
         this.props.ClassMenu();
    }
    addModel(){
        this.setState({
            visible1:true
        })
    }
    render() {
        console.log(this.props)
        let ylClassificationDtoList = this.props.classList.ylClassificationDtoList;
        console.log(ylClassificationDtoList)
        return (
            <Layout>
                <Header className="header">
                <div className="logo" />
                             <Menu
                                onClick={this.handleClick}
                                mode="horizontal"
                                defaultSelectedKeys={['2']}
                                style={{ lineHeight: '64px'}}
                            >
                                    <SubMenu key={1} title={<span className="submenu-title-wrapper"><Icon type="setting" />找船</span>}>
                                    <MenuItemGroup >
                                        <Menu.Item key="setting:1">快速找船</Menu.Item>
                                        <Menu.Item key="setting:2">快速找船</Menu.Item>
                                    </MenuItemGroup>
                                    </SubMenu>
                                    <SubMenu key={2} title={<span className="submenu-title-wrapper"><Icon type="setting" />运力管理</span>}>
                                    <MenuItemGroup >
                                        <Menu.Item key="setting:1">全部运力</Menu.Item>
                                        <Menu.Item key="setting:2">可监控</Menu.Item>
                                        <Menu.Item key="setting:3">已认证</Menu.Item>
                                        <Menu.Item key="setting:4">人工认证中</Menu.Item>
                                    </MenuItemGroup>
                                    </SubMenu>
                                    <SubMenu key={3} title={<span className="submenu-title-wrapper"><Icon type="setting" />运输管理</span>}>
                                    <MenuItemGroup >
                                        <Menu.Item key="setting:1">新增运输计划</Menu.Item>
                                        <Menu.Item key="setting:2">正在运输中</Menu.Item>
                                        <Menu.Item key="setting:3">已完成运输</Menu.Item>
                                    </MenuItemGroup>
                                    </SubMenu>
                                    <SubMenu  key={8} title={<span className="submenu-title-wrapper"><Icon type="setting" />经营分析</span>}>
                                    <MenuItemGroup >
                                        <Menu.Item key="setting:1">Option 1</Menu.Item>
                                        <Menu.Item key="setting:2">Option 2</Menu.Item>
                                    </MenuItemGroup>
                                    </SubMenu>
                                    <SubMenu key={4} title={<span className="submenu-title-wrapper"><Icon type="setting" />系统配置</span>}>
                                    <MenuItemGroup >
                                        <Menu.Item key="setting:1">Option 1</Menu.Item>
                                        <Menu.Item key="setting:2">Option 2</Menu.Item>
                                    </MenuItemGroup>
                                    </SubMenu>
                                    <SubMenu key={5} title={<span className="submenu-title-wrapper"><Icon type="setting" />费用</span>}>
                                    <MenuItemGroup >
                                        <Menu.Item key="setting:1">Option 1</Menu.Item>
                                        <Menu.Item key="setting:2">Option 2</Menu.Item>
                                    </MenuItemGroup>
                                    </SubMenu>
                                    <SubMenu key={6} title={<span className="submenu-title-wrapper"><Icon type="setting" />客服</span>}>
                                    <MenuItemGroup >
                                        <Menu.Item key="setting:1">在线客服</Menu.Item>
                                        <Menu.Item key="setting:2">创建工单</Menu.Item>
                                        <Menu.Item key="setting:2">建议反馈</Menu.Item>
                                    </MenuItemGroup>
                                    </SubMenu>
                                    <SubMenu key={7} title={<span className="submenu-title-wrapper"><Icon type="setting" />龙小鱼</span>}>
                                    <MenuItemGroup >
                                        <Menu.Item key="setting:1">个人信息</Menu.Item>
                                        <Menu.Item key="setting:2">公司配置</Menu.Item>
                                        <Menu.Item key="setting:2">员工管理</Menu.Item>
                                    </MenuItemGroup>
                                    </SubMenu>
                            </Menu>
                
                </Header>
                <Layout >
                <Sider width={200} style={{ background: '#fff' }}>
                    <Menu
                    mode="inline"
                    defaultSelectedKeys={['1']}
                    defaultOpenKeys={['sub1']}
                    style={{ height: '100%', borderRight: 0,background: '#F1F4FA' }}
                    >
                    <SubMenu className = 'colo' key="sub1" title={<span><Icon type="user" />自有运力</span>}>
                        <Menu.Item key="1"><Link  to = '/menuList/capaCityTable1/1'>全部</Link></Menu.Item>
                        <Menu.Item key="2"><Link  to = '/menuList/capaCityTable2/2'>可监控</Link></Menu.Item>
                        <Menu.Item key="3"><Link  to = '/menuList/capaCityTable3/3'>无监控</Link></Menu.Item>
                        <Menu.Item key="4"><Link  to = '/menuList/capaCityTable4/4'>已认证</Link></Menu.Item>
                        <Menu.Item key="5"><Link  to = '/menuList/capaCityTable5/5'>人工认证</Link></Menu.Item>

                        
                    </SubMenu>
                    <SubMenu key="sub2" title={<span><Icon type="laptop" />运力分类</span>}>
                        {
                            !ylClassificationDtoList ?'' :
                            ylClassificationDtoList.map((item,index)=>
                               <Menu.Item key={7+index}><Link  to = {'/menuList/classList/'+item.classificationId}>{item.classificationName}</Link></Menu.Item>
                            )
                        }
                        <Menu.Item onClick={this.addModel.bind(this)} key="1118">添加分类</Menu.Item>
                    </SubMenu>
                    </Menu>
                </Sider>
                <Layout >
                    <Breadcrumb style={{ margin: '16px 0' }}>
                    <Breadcrumb.Item>Home</Breadcrumb.Item>
                    <Breadcrumb.Item>List</Breadcrumb.Item>
                    <Breadcrumb.Item>App</Breadcrumb.Item>
                    </Breadcrumb>
                    <Content style={{ background: '#fff' }}>
                            <Route  path='/menuList/capaCityTable1/:id'  component={CapaCityTable1}> </Route>
                            <Route  path='/menuList/capaCityTable2/:id'  component={CapaCityTable2}> </Route>
                            <Route  path='/menuList/capaCityTable3/:id'  component={CapaCityTable3}> </Route>
                            <Route  path='/menuList/capaCityTable4/:id'  component={CapaCityTable4}> </Route>
                            <Route  path='/menuList/capaCityTable5/:id'  component={CapaCityTable5}> </Route>
                            <Route  path='/menuList/12'  component={Transport}> </Route>
                            <Route  path='/menuList/classification/:id'  component={ClassiFicationList}> </Route>
                            <Route  path='/menuList/classification1/:id'  component={ClassIficationList1}> </Route>
                            <Route  path='/menuList/classList/:id'  component={ClassList}> </Route>
                    </Content>
                </Layout>
            </Layout>
            <AddClassModel visible = {this.state.visible1} showModel = {this.showModel.bind(this)}/>
  </Layout>
        )
    }
}